import http from '@/util/request.js'

export default {
    // 根据id获取地址信息
    getAddrById: (id) => {
        return http({
            url: `/api/user/deliveryaddr/id/${id}`,
            method: 'get'
        })
    },

    // 根据用户id获取地址列表
    getAddrsByUserId: (userId) => {
        return http({
            url: `/api/user/deliveryaddr/user/${userId}`,
            method: 'get'
        })
    },

    // 添加地址
    addAddr: (data) => {
        return http({
            url: '/api/user/deliveryaddr/add',
            method: 'post',
            data
        })
    },

    // 更新地址
    updateAddr: (data) => {
        return http({
            url: '/api/user/deliveryaddr/update',
            method: 'put',
            data
        })
    },

    // 删除地址（软删除）
    deleteAddr: (id) => {
        return http({
            url: `/api/user/deliveryaddr/delete/${id}`,
            method: 'delete'
        })
    },

    // 获取地址列表
    getAddrList: (data) => {
        return http({
            url: '/api/user/deliveryaddr/list',
            method: 'get',
            params: data
        })
    },

    // 获取地址分页列表
    getAddrPage: (current, size, data) => {
        return http({
            url: '/api/user/deliveryaddr/page',
            method: 'get',
            params: {
                current: current,
                size: size,
                ...data
            }
        })
    }
}
